Raised This Month: $51 Target: $400
 12% 

Need help with buy thing


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
[X]-RayCat
Senior Member
Join Date: Sep 2006
Old 08-07-2007 , 09:49   Need help with buy thing
Reply With Quote #1

How to detect the weapon what player bought?
[X]-RayCat is offline
X-Script
BANNED
Join Date: Jul 2007
Location: (#504434)
Old 08-07-2007 , 11:34   Re: Need help with buy thing
Reply With Quote #2

I'm not sure but I found something close, I couldn't find anything to check the weapon the player just bought. But what you can do is check if the player is in the buyzone cs_get_user_buyzone and then check what weapon he has and if it's a glock or usp then don't do anything but if it's something else like a AK47 or M4A1 then do what you want to do.

But if you find out how to detect it, then don't go with my suggestion.

get_user_weapon

X-Script is offline
VEN
Veteran Member
Join Date: Jan 2005
Old 08-07-2007 , 12:50   Re: Need help with buy thing
Reply With Quote #3

Code:
#include <amxmodx> #define MAX_CLIENTS 32 new g_weapons[MAX_CLIENTS + 1] public plugin_init() {         register_event("Money", "event_money", "be") } public client_command(id) {         static dummy[32], dummy2         g_weapons[id] = get_user_weapons(id, dummy, dummy2) } public event_money(id) {         new old_weapons = g_weapons[id]         client_command(id)         new new_weapon = g_weapons[id] & ~old_weapons         if (new_weapon) {                 new x = -1                 do ++x; while ((new_weapon /= 2) >= 1)                 static wname[32]                 get_weaponname(x, wname, sizeof wname - 1)                 server_print("Player [ClientIndex=%d] has bought ^"%s^" [WeaponIndex=%d]", id, wname, x)         } }
VEN is offline
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 08-07-2007 , 13:04   Re: Need help with buy thing
Reply With Quote #4

Nice work VEN! Works...i may use this someday...Gj
__________________
Still...lovin' . Connor noob! Hello
Alka is offline
X-Script
BANNED
Join Date: Jul 2007
Location: (#504434)
Old 08-07-2007 , 13:17   Re: Need help with buy thing
Reply With Quote #5

Ahh, okay I see now but can you explain to me why you have to do old_weapons?
X-Script is offline
[X]-RayCat
Senior Member
Join Date: Sep 2006
Old 08-07-2007 , 13:38   Re: Need help with buy thing
Reply With Quote #6

Thanks for that VEN.

Last edited by [X]-RayCat; 08-07-2007 at 13:41.
[X]-RayCat is offline
VEN
Veteran Member
Join Date: Jan 2005
Old 08-08-2007 , 12:28   Re: Need help with buy thing
Reply With Quote #7

Quote:
why you have to do old_weapons?
To do comparision of player's weapons before/after buying.

It's possible to do very insignificant optimization though:
Code:
        new weapon = g_weapons[id]         client_command(id)         weapon = g_weapons[id] & ~weapon         if (weapon) {                 // ...

Last edited by VEN; 08-08-2007 at 12:33.
VEN is offline
X-Script
BANNED
Join Date: Jul 2007
Location: (#504434)
Old 08-08-2007 , 12:30   Re: Need help with buy thing
Reply With Quote #8

Okay thank you.
X-Script is offline
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 08-08-2007 , 17:41   Re: Need help with buy thing
Reply With Quote #9

VEN, i've founded something ...?! 0_o
If i buy a flash and after that another flash , the message is not printed!
Alka is offline
VEN
Veteran Member
Join Date: Jan 2005
Old 08-08-2007 , 17:54   Re: Need help with buy thing
Reply With Quote #10

Yes because this is for "new" weapons. In your case you would need to compare flash ammo before/after buying.
VEN is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 04:28.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode